package bankapp;

import bankapp.util.BankSystemConstants;
import frmsystem.Domain;
import frmsystem.IAccount;
import frmsystem.IEntry;
import frmsystem.IParty;

public class BankSystem extends Domain{
	
	private static BankSystem instance;
	
	private BankSystem(){
		creator = new BankCreator();
	}

	public static BankSystem getInstance() {
		if(instance == null){
			instance = new BankSystem();
		}
		return instance;
	}

	@Override
	public String[][] getAccountData() {
		String[][] strings = new String[accounts.size()][9];
		int i=0;
		for(IParty party : parties){
			for(IAccount acc : party.getAccounts()){
				strings[i][0] = party.getName();
				strings[i][1] = party.getStreet();
				strings[i][2] = party.getCity();
				strings[i][3] = party.getState();
				strings[i][4] = party.getZip();
				strings[i][5] = party.getType() == BankSystemConstants.PARTY_PERSON ? "P": "C";
				strings[i][6] = acc.getAccountNo();
				strings[i][7] = acc.getName();
				strings[i][8] = Double.toString(acc.getBalance());
 				i++;
			}
		}
		
		return strings;
	}

	@Override
	public String[] getTitles() {
		return new String[]{"Name", "Street", "City", "State", "Zip", "P/C", "Account No", "Ch/S", "Amount"};
	}
	
	

}
